<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Data-Table 表格</title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
</head>
<body class="body">
<fieldset class="layui-elem-field layui-field-title">
    <legend>已存数据展示</legend>
</fieldset>
<blockquote class="layui-elem-quote layui-quote-nm">
    <div class="site-demo-flow" id="LAY_demo3">
        <ul>
            <li style="display: inline-block">
                <div>
                    <img lay-src="../frame/layui/images/face/files.PNG" height="80" width="80" style="margin: 10px 35px">
                </div>
                <div style="color: #00C0F7;text-align: center">
                    设备故障率统计分析表
                </div>
            </li>
            <li style="display: inline-block">
                <div>
                    <img lay-src="../frame/layui/images/face/files.PNG" height="80" width="80" style="margin: 10px 35px">
                </div>
                <div style="color: #00C0F7;text-align: center">
                    设备使用寿命统计分析
                </div>
            </li>
        </ul>
    </div>
</blockquote>
<!-- 工具集 -->
<fieldset class="layui-elem-field layui-field-title">
    <legend>拖拽筛选</legend>
</fieldset>
<div class="layui-upload-drag" id="test10">
    <i class="layui-icon"></i>
    <p>点击将文件拖拽到此处筛选</p>
</div>
<fieldset class="layui-elem-field layui-field-title">
    <legend>表格结构</legend>
</fieldset>
<div class="my-btn-box">
    <span class="fl">
        <a class="layui-btn layui-btn-danger radius btn-delect" id="btn-delete-all">批量删除</a>
        <a class="layui-btn btn-add btn-default" id="btn-add">添加</a>
        <a class="layui-btn btn-add btn-default" id="btn-refresh"><i class="layui-icon">&#x1002;</i></a>
    </span>
    <span class="fr">
        <span class="layui-form-label">搜索条件：</span>
        <div class="layui-input-inline">
            <input type="text" autocomplete="off" placeholder="请输入搜索条件" class="layui-input">
        </div>
        <button class="layui-btn mgl-20">查询</button>
    </span>
</div>
<div>
    <strong>ETL转换表结构</strong>
</div>
<!-- 表格 -->
<div id="dateTable"></div>

<script type="text/javascript" src="../frame/layui/layui.js"></script>
<script type="text/javascript" src="../js/index.js"></script>
<script type="text/javascript">

    // layui方法
    layui.use(['table', 'form', 'layer', 'vip_table'], function () {

        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , vipTable = layui.vip_table
            , $ = layui.jquery;

        // 表格渲染
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            , height: vipTable.getFullHeight()    //容器高度
            , cols: [[                  //标题栏
                {checkbox: true, sort: true, fixed: true, space: true}
                , {field: 'id', title: '表名', width: 210}
                , {field: 'name', title: '用户名', width: 120}
                , {field: 'permission_group_name', title: '权限组', width: 120}
                , {field: 'create_time', title: '创建时间', width: 180}
                , {field: 'last_id', title: '被转换表', width: 250}
                , {field: 'status', title: '状态', width: 70}
                , {fixed: 'right', title: '操作', width: 220, align: 'center', toolbar: '#barOption'}//这里的toolbar值是模板元素的选择器
            ]]
            , id: 'dataCheck'
            , url: './../json/data_table.json'
            , method: 'get'
            , page: true
            , limits: [30, 60, 90, 150, 300]
            , limit: 15 //默认采用15
            , loading: false
            , done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);

                //得到当前页码
                console.log(curr);

                //得到数据总量
                console.log(count);
            }
        });

        // 获取选中行
        table.on('checkbox(dataCheck)', function (obj) {
            layer.msg('123');
            console.log(obj.checked); //当前是否选中状态
            console.log(obj.data); //选中行的相关数据
            console.log(obj.type); //如果触发的是全选，则为：all，如果触发的是单选，则为：one
        });

        // 刷新
        $('#btn-refresh').on('click', function () {
            tableIns.reload();
        });


        // you code ...

    });


    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //拖拽上传
        upload.render({
            elem: '#test10'
            ,url: '/upload/'
            ,done: function(res){
                console.log(res)
            }
        });
    });






</script>
<!-- 表格操作按钮集 -->
<script type="text/html" id="barOption">
    <a class="layui-btn layui-btn-mini layui-btn-danger" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-mini layui-btn-normal" lay-event="edit">数据详情</a>
    <a class="layui-btn layui-btn-mini" lay-event="detail">数据分析</a>
</script>
</body>
</html>